16. Visualizing CNNs
Visualizing CNNs
Let’s look at an example CNN to see how it works in action.
The CNN we will look at is trained on ImageNet as described in this paper by Zeiler and Fergus. In the images below (from the same paper), we’ll see what each layer in this network detects and see how each layer detects more and more complex ideas.
Layer 1
The images above are from Matthew Zeiler and Rob Fergus' deep visualization toolbox, which lets us visualize what each layer in a CNN focuses on.
Each image in the above grid represents a pattern that causes the neurons in the first layer to activate - in other words, they are patterns that the first layer recognizes. The top left image shows a -45 degree line, while the middle top square shows a +45 degree line. These squares are shown below again for reference.
Let's now see some example images that cause such activations. The below grid of images all activated the -45 degree line. Notice how they are all selected despite the fact that they have different colors, gradients, and patterns.
So, the first layer of our CNN clearly picks out very simple shapes and patterns like lines and blobs.
Layer 2
The second layer of the CNN captures complex ideas.
As you see in the image above, the second layer of the CNN recognizes circles (second row, second column), stripes (first row, second column), and rectangles (bottom right).
The CNN learns to do this on its own. There is no special instruction for the CNN to focus on more complex objects in deeper layers. That's just how it normally works out when you feed training data into a CNN.
Layer 3
The third layer picks out complex combinations of features from the second layer. These include things like grids, and honeycombs (top left), wheels (second row, second column), and even faces (third row, third column).
We'll skip layer 4, which continues this progression, and jump right to the fifth and final layer of this CNN.
Layer 5
The last layer picks out the highest order ideas that we care about for classification, like dog faces, bird faces, and bicycles.
On to TensorFlow
This concludes our high-level discussion of Convolutional Neural Networks.
Next you'll practice actually building these networks in TensorFlow.